log.js ➔ warn   A
last analyzed

Complexity

Conditions 1
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 2
dl 0
loc 3
rs 10
nop 0
1
/*eslint no-unused-expressions: 0*/
2
/*eslint no-undef: 0*/
3
4
import { isUndefined } from 'lodash';
5
6
if (isUndefined(IS_LOGGING)) {
0 ignored issues
show
Bug introduced by
The variable IS_LOGGING seems to be never declared. If this is a global, consider adding a /** global: IS_LOGGING */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
7
  throw new Error('IS_LOGGING must be set.');
8
}
9
10
if (isUndefined(LOGGING_LEVEL)) {
0 ignored issues
show
Bug introduced by
The variable LOGGING_LEVEL seems to be never declared. If this is a global, consider adding a /** global: LOGGING_LEVEL */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
11
  throw new Error('LOGGING_LEVEL must be set.');
12
}
13
14
export const LogLevels = {
15
  LOG: 1,
16
  INFO: 2,
17
  WARN: 3,
18
  ERROR: 4,
19
  DEBUG: 5
20
};
21
22
export function log() {
23
  shouldLog(LogLevels.LOG) && console.log.apply(console, arguments);
24
}
25
26
export function info() {
27
  shouldLog(LogLevels.INFO) && console.info.apply(console, arguments);
28
}
29
30
export function warn() {
31
  shouldLog(LogLevels.WARN) && console.warn.apply(console, arguments);
32
}
33
34
export function error() {
35
  shouldLog(LogLevels.ERROR) && console.error.apply(console, arguments);
36
}
37
38
export function debug() {
39
  shouldLog(LogLevels.DEBUG) && console.debug.apply(console, arguments);
40
}
41
42
function shouldLog(logLevel) {
43
  return Boolean(IS_LOGGING) && LOGGING_LEVEL >= logLevel;
0 ignored issues
show
Bug introduced by
The variable IS_LOGGING seems to be never declared. If this is a global, consider adding a /** global: IS_LOGGING */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable LOGGING_LEVEL seems to be never declared. If this is a global, consider adding a /** global: LOGGING_LEVEL */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
44
}
45